package game.core.util
{
	import flash.utils.Dictionary;

	/**
	 * 界面资源的 ApplicactionDomain 对象缓存
	 * 
	 */
	public class Cache
	{
		/**
		 * 键值字典	
		 * */
		private static var _cache:Dictionary = new Dictionary();
				
		/**
		 * 是否包含指定的键名	
		 * */
		public static function hasCache(key:Object):Boolean {
			return _cache[key] != null;
		}
		
		/**
		 * 添加一个新数据
		 * */
		public static function addCache(key:Object, value:Object):Object {
			var result:Object = null;
			if (hasCache(key)) {
				result = getCache(key);
				_cache[key] = value;
			} else {
				_cache[key] = value;
			}
			return result;
		}
		
		/**
		 * 移除指定的数据	
		 * */
		public static function removeCache(key:Object):*{
			var result:Object = null;
			if (hasCache(key)) {
				result = _cache[key];
				delete _cache[key];
			}
			return result;
		}
		
		/**
		 * 获取指定的数据	
		 * */
		public static function getCache(key:Object):Object {
			return _cache[key];
		}
	}
}